var mongoose = require('mongoose');

/**
 * 内容模型
 */
var newsSchema = new mongoose.Schema({
    //状态
    status: {
        type: String,
        default: 'draft',
        enum: ['draft', 'pushed']
    },

    // 放入回收站
    deleted: {
        type: Boolean,
        default: false
    },

    //栏目 ID
    category: {
        type: Number,
        default:-1
    },

    //标题
    title: {
        type: String,
        default:""
    },

    //别名
    alias: {
        type: String,
        default:""
    },

    //发布人
    user: {
        type: String,
        default:"admin"
        
    },

    //日期
    date: {
        type: Date,
        default: Date.now
    },

    //阅读量
    reading: {
        //总阅读量
        type: Number,
        default: 0       
    },

    //缩略图
    thumbnail: {
        type: String,
        default:""
    },

    //媒体
    media:
        {
            type: String,
            default:""
        },

    //摘要
    abstract:
    {
        type:String,
        default:""
    },

    //内容
    content:
    {
        type:String,
        default:""
    },

    //标签
    tags: [String]
}, {
        collection: 'news',
        id: false
    });

module.exports = mongoose.model('News', newsSchema);

